//配置路由相关信息
import VueRouter from "vue-router";
import Vue from "vue";
//懒加载各个组件
const Home = () => import('../views/home/Home.vue')
const Category = () => import('../views/category/Category')
const Cart = () => import('../views/cart/Cart')
const Profile = () => import('../views/profile/Profile')


//1.先拿到Vue，通过Vue.use(插件),安装插件
Vue.use(VueRouter);
//2.创建路由对象，并进行映射,注意是path和component
const routes=[
  {
    path:'/home',
    component: Home
  },
  {
    path:'/category',
    component: Category
  },
  {
    path:'/cart',
    component: Cart
  },
  {
    path:'/profile',
    component: Profile
  },
]
const router=new VueRouter({
  //在routes里面配置路径和组件之间的映射关系，一个url对应一个组件,一个映射关系就是一个对象
  routes,
  //将路径显示方式改为history模式
  mode: 'history'
})
//3.将router对象传入到Vue实例中,先导出，然后在src/mian.js中导入
export default router
